package practice1_100;

public class Offer27 {
    public TreeNode mirrorTree(TreeNode root) {
        exchange(root.left,root.right);
        return root;
    }

    public void exchange(TreeNode left,TreeNode right){
        if(left==null&&right==null)return;
        if(left!=null||right!=null){
            TreeNode temp= left;
            left= right;
            right=temp;
        }
        exchange(left.left,left.right);
        exchange(right.left,right.right);
    }

    public static void main(String[] args) {
      TreeNode a= new   Offer27().mirrorTree(        new TreeNode(1,new TreeNode(2),new TreeNode(3)));
        System.out.println(a);
    }
}
